package wec_wallet.ebo.com.common;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2018/3/12.
 */

public class SharedPreference {

    public static String name = "hk_wallet";
    public static String ISOPENSAFETY = "isOpenSafety";//一键开启
    public static String USERID = "userId";//用户id
    public static String ISOPENIntercept = "isOpenIntercept";//智能诈骗拦截
//
//    /**
//     * 安全界面 是否开启了安全保护
//     *
//     * @param context
//     * @param isOpenSafety true 开启  false 未开启
//     */
//    public static void putOpen(Context context, String userId, Boolean isOpenSafety) {
//        SharedPreferences sp = context.getSharedPreferences(name, Context.MODE_PRIVATE);
//        SharedPreferences.Editor editor = sp.edit();
//        editor.putString(USERID, userId);
//        editor.putBoolean(ISOPENSAFETY, isOpenSafety);
//        editor.commit();
//    }
//
//    /**
//     * 根据用户id判断用户是否开启了安全保护功能
//     *
//     * @param context
//     * @param userId
//     * @return
//     */
//    public static Boolean getIsOpen(Context context, String userId) {
//        Boolean b = false;
//        SharedPreferences pre = context.getSharedPreferences(name, Context.MODE_PRIVATE);
//        if (userId.equals(pre.getString(USERID, ""))) {
//            b = pre.getBoolean(ISOPENSAFETY, false);
//        }
//        return b;
//    }


    /**
     * 是否开启了智能诈骗拦截
     *
     * @param context
     * @param isOpens true 开启  false 未开启
     */
    public static void putOpenIntercept(Context context, String userId, boolean isOpens) {
        SharedPreferences sp = context.getSharedPreferences(name, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString(USERID, userId);
        editor.putBoolean(ISOPENIntercept, isOpens);
        editor.commit();
    }

    /**
     * 根据用户id判断用户是否开启了智能拦截诈骗功能
     *
     * @param context
     * @param userId
     * @return
     */
    public static boolean getIsOpenIntercept(Context context, String userId) {
        Boolean b = false;
        SharedPreferences pre = context.getSharedPreferences(name, Context.MODE_PRIVATE);
        if (userId.equals(pre.getString(USERID, ""))) {
            b = pre.getBoolean(ISOPENIntercept, false);
        }
        return b;
    }


}
